#!/usr/bin/Python
# -*- coding: utf-8 -*-
class HtmlOutputer(object):
    def __init__(self):
        self.datas = []

    def collect_data(self, data):
        if data is None:
            return
        self.datas.append(data)


    def output_html(self):
        fout = open('output.html','w')

        fout.write('<html>')
        fout.write('<body>')
        fout.write('<table border="1">')
        count = 1
        for data in self.datas:
            fout.write('<tr>')
            fout.write('<td>%d</td><td>%s</td>' % (count,data['title'].encode('utf-8')))
            count += 1
            for img in data['imgs']:
                fout.write('<td><img src="%s"/></td>' % img.encode('utf-8'))
            fout.write('</tr>')
        fout.write('</table>')
        fout.write('</body>')
        fout.write('</html>')

        fout.close()